<?php

namespace App\Models;

use App\Models\Base;

/**
 * App\Models\Role
 *
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Auth[] $auths
 * @property-read int|null $auths_count
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Role newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Role newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Role query()
 * @mixin \Eloquent
 */
class Role extends Base
{
    //角色与权限多对多
    public function auths()
    {
        /**
         * 参数1 关联的模型
         * 参数2 中间表的表名
         * 参数3 本模型的外键id
         * 参数4 关联模型的外键id
         */
        return $this->belongsToMany(Auth::class,'role_auth','role_id','auth_id');
    }
}
